﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="KeepAliveHttp.index" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>测试页面</title>
    <script type="text/javascript" src="public/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">

        function requestLongHttp(sessionid) {
            $.post("LongPolling.ashx", { 'sessionid': sessionid }, function (r) {
                if (r) {
                    requestLongHttp(sessionid);
                    //给id为showMsg的标签赋值
                    $("#showMsg").html(r);
                }
            }, 'text');
        }
        $(function () {
            $("#btnConnect").click(function () {
                $.post("connection.ashx", {}, function (r) {
                    if (r) {
                        $("#txtSessionId").val(r);
                        requestLongHttp(r);
                    }
                }, 'text');

            });
        });
    </script>
</head>
<body>

    <form id="form1" runat="server">
        <div>
            <input id="btnConnect" type="button" value="连接" /><br />
            sessionid:<input id="txtSessionId" readonly="readonly" type="text" value="" /><br />
            <label id="showMsg"></label>
        </div>
    </form>
</body>
</html>
